package com.cysyz.commonservice.mycommonservice.login.impl;

import com.cysyz.commonservice.mycommonservice.BaseService;
import com.cysyz.commonservice.mycommonservice.exception.InputValueIsNullOrEmptyException;
import com.cysyz.commonservice.mycommonservice.exception.ValueNotMatchException;
import com.cysyz.commonservice.mycommonservice.login.LoginService;
import com.cysyz.commonservice.mycommonservice.support.Loginable;

public class LoginServiceImpl extends BaseService implements LoginService{
	
	@Override
	public Loginable login(Loginable input) throws InputValueIsNullOrEmptyException, ValueNotMatchException, InvalidIdException {
		checkNullOrEmpty(input, "id","password");
		Loginable entityDB = dao.get(input.getClass(), input.getId().trim());
		if (entityDB != null) {
			checkValueEqual(input, entityDB, "password");
		}
		return entityDB;
	}
}
